import React, { Profiler } from "react";
import Modal from "./components/modal";

export default class extends React.PureComponent {
  constructor(props) {
    super(props);
    this.state = {
      show: false,
    };
  }
  cancel() {
    this.setState({ show: false });
    console.log("---");
  }
  submit() {
    console.log("---调接口");
    this.setState({ show: false });
  }
  //测试性能（只对开发环境有用）
  test(id, phase, _a, _b, _c, commitTiem) {
    console.log("-渲染性能测试", id, _c, commitTiem);
  }
  render() {
    const { show } = this.state;
    return (
      <div>
        <h2>学习组合</h2>
        <button onClick={() => this.setState({ show: true })}>点击</button>
        <Profiler id="modal" onRender={this.test.bind(this)}>
          {/* <Modal>
            visible={show}
            onCancel={() => this.cancel()}
            title={<div>自定义标题</div>}
            onOk={() => this.submit()}
            type='error' tipTitle ='Use hooks'
          </Modal> */}
        </Profiler>
      </div>
    );
  }
}
